<%@ page language="java" import="java.util.*"  import="com.yb.util.comm.RequestUtil,com.yb.domain.member.TsSysuser,com.yb.util.comm.Contants;" pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<link rel="stylesheet" type="text/css" href="<%=basePath %>/resource/js/kindeditor/skins/default.css"></link>
<script type="text/javascript" src="<%=basePath%>/resource/js/kindeditor/kindeditor.js"></script>
<script type="text/javascript" src="<%=basePath %>/resource/js/jquery-1.4.2.js"></script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    
    <title>口碑评价</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<%
     String userId="";
        TsSysuser  sys = (TsSysuser) RequestUtil.getLoginUserFromSession(request,Contants.SESSION_USER);
         String sId="";        
         if(null != session.getAttribute("modifyBrandid") )
         {
        	 sId=(String) session.getAttribute("modifyBrandid");
         }   	
	 if(sys!=null)
	 {
		 userId=sys.getId().toString();
	 }
	%>
  </head>
  
  <body>
             <div> <font size="2">评价态度：</font><select id="type">
             <option value="-1">---请选择---</option>
             <option value="1">好评</option>
             <option value="2">坏评</option>
             </select></div>
            <div> <font size="2">  标题：</font>  <input type="text" name="title" maxlength="75" id="title"></div>
            <div>    <textarea rows="20" cols="50"  id="content"></textarea></div>
            <input type="button" value="提交评价" onclick="register()">
  </body>
  <script>
      var basePath="<%=basePath %>";
      var  userid="<%=userId %>";
       var  sId="<%=sId %>";
       
            function  register()
            {
                
                 if(""==userid)
                 {
                   alert('评价请先登录');
                   return;
                 }
                
                $.post(basePath+"/user/checkSheng.shtml?id="+userid+"&brandId="+sId
                 ,function(message){
				 if(message == "3")
				   {
				     alert("只能业主评论"); 
					 return;
				   }
				   if(message == "2")
				   {
				     alert("您没有拼购该商家，不能评论"); 
					 return;
				   }
				   if(message == "4"){
				               var  type=$("#type").val();
                  if("-1"==type)
                  {
                     alert('请选择评价态度');
                     $("#type").focus();
                    return;
                  }
                  var  title=$("#title").val();
                  if(""==title){
                     alert("请选择标题");
                     $("#title").focus();
                     return;
                  }
              //    $("#content").val(KE.util.getData('content'));
                  var content =$("#content").val();
                $.post(basePath+"/pingjia/saveOrUpdate.shtml?pg.type="+type+"&pg.title="+encodeURI(encodeURI(title))+"&pg.content="+encodeURI(encodeURI(content))+"&pg.yeId="+userid+"&pg.brandId="+sId
               ,function(message){
				if(message == "1"){
					alert("评价成功");
					$("#title").val("");
					KE.html('content','');
					parent.location.reload();

				}else if(message == "2") {
					alert("评价出错");
					return;
				}
			     })
				   }
				 
			    })
			    
          
                 
            }
	/*		KE.show({
				id : 'content',
				loadStyleMode : false,
				resizeMode : 0,
				allowUpload:true, //允许上传图片 
				imageUploadJson:'<%=basePath%>/comutil/upload.shtml',    
				items : [
				'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|','image']
			});*/

		</script>
</html>
